package com.stox.client.ui.javafx.chartingy.widget.toolbar;


import javafx.event.ActionEvent;
import javafx.event.EventHandler;
import javafx.scene.control.Button;
import javafx.scene.control.ToolBar;

import com.stox.client.ui.javafx.chartingy.view.ChartingView;
import com.stox.client.ui.javafx.chartingy.widget.IndicatorChooserPopupControl;
import com.stox.client.ui.javafx.core.util.CSS;
import com.stox.client.ui.javafx.core.util.UI;
import com.stox.client.workbench.ui.javafx.stage.StoxStage;
import com.stox.shared.i18n.MessageSource;

public class ChartingToolBar extends ToolBar {

	private final Button indicatorsButton = UI.control(new Button(MessageSource.get("Indicators")), MessageSource.get("Add.an.Indicator"), true, false, CSS.green);
	private final Button screensButton = UI.control(new Button(MessageSource.get("Screens")), MessageSource.get("Add.a.Screen"), true, false, CSS.green);
	private final Button patternsButton = UI.control(new Button(MessageSource.get("Patterns")), MessageSource.get("Add.a.Pattern"), true, false, CSS.green);

	public ChartingToolBar(final ChartingView chartingView) {
		setMaxWidth(Double.MAX_VALUE);
		UI.style(this, CSS.chartingToolBar);
		indicatorsButton.setOnAction(new EventHandler<ActionEvent>() {
			@Override
			public void handle(final ActionEvent event) {
				final IndicatorChooserPopupControl chooser = new IndicatorChooserPopupControl(chartingView);
				chooser.show(StoxStage.getInstance());
			}
		});
		getItems().addAll(new BasicTools(chartingView), indicatorsButton, screensButton, patternsButton, new ZoomTools(chartingView), UI.spacer());
	}
}
